#页面类
    # A3mall 搜索
import time

from unit_729.Base.Base import Base
from selenium.webdriver.common.by import By
class Page1(Base):
    # 点击登录
    login_loc = (By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[1]/a')

    def login(self):
        self.click(self.login_loc)

    # 登录文本
    d_loc = (By.CLASS_NAME, 'reg-new')

    def d(self):
        return self.text(self.d_loc)

    # 输入用户名
    username_loc = (By.NAME, 'username')

    def username(self):
        self.send_keys(self.username_loc, '15821860061')

    # 输入密码
    password_loc = (By.NAME, 'password')

    def password(self):
        self.send_keys(self.password_loc, '12345678')

    # 点击登录按钮
    finish_btn_loc = (By.XPATH, '//*[@id="theForm"]/div[5]/a')
    # 1.定位器
    keywords_loc = (By.XPATH, '/html/body/div[2]/div/div/form/div[1]/input')


    # 2.页面元素的封装
    def keywords(self):
        self.send_keys(self.keywords_loc, '手机')

    # 点击搜索
    search_btn_loc = (By.XPATH, '//*[@id="searchForm"]/div[2]/input')

    def search_btn(self):
        self.click(self.search_btn_loc)
    def A3mall_search_01(self):
        self.open_url('http://10.59.9.12:7001')
        self.login()
        d = self.d()
        print(d)
        assert '会员登录' in d
        time.sleep(1)
        self.username()
        self.password()
        time.sleep(10)
        self.finish_btn()
        time.sleep(3)
        self.keywords()
        self.search_btn()
